#include "defs.h"
#include "src/core/xmltag.h"
-#if REALLY_MINIMAL
-ff_vecs_t delbin_vecs;
-#else
#include <assert.h>
#define MYNAME "delbin"
const char* s = p->name + p->name_size;
unsigned nn = le_readu16(s);
if (notes_max < notes_i + nn) {
+#if NEW_STRINGS
+// This section needs a serious rethinking.
+#else
char* old = wp->notes;
+#endif
if (notes_max == 0) {
notes_max = nn;
}
notes_max += notes_max;
} while (notes_max < notes_i + nn);
wp->notes = (char*) xmalloc(notes_max);
+#if NEW_STRINGS
+#else
if (old) {
memcpy(wp->notes, old, notes_i);
xfree(old);
}
+#endif
}
if (nn) {
#if NEW_STRINGS
-#warning gross code avoided.
-abort();
+ // Is this really what this code was trying to do?
+ wp->notes += QString::fromUtf8(s + 2, nn);
#else
memcpy(wp->notes + notes_i, s + 2, nn);
#endif
if (0 == (wp->icon_descr.compare("Geocache Found"))) {
gc_sym = 124;
}
+#if NEW_STRINGS
+ if (!wp->description.isEmpty()) {
+#else
if (wp->description) {
+#endif
gbfputs(wp->description, fd);
if (!wp->gc_data->placer.isEmpty()) {
gbfprintf(fd, " by %s", wp->gc_data->placer.toUtf8().data());
{
message_t m;
msg_waypoint_t* p;
+#if NEW_STRINGS
+ QString name = wp->shortname;
+#else
const char* name = wp->shortname;
- unsigned name_size;
+#endif
char* notes;
+ unsigned name_size;
unsigned notes_size = 0;
unsigned extended_notes_size = 0;
- char* notes_freeable = NULL;
+ const char* notes_freeable = NULL;
int symbol = -1;
float elev = UNKNOWN_ELEV;
char* pp;
if (waypt_empty_gc_data(wp)) {
+#if NEW_STRINGS
+ notes = xstrdup(wp->notes);
+ if (notes == NULL && wp->description.isEmpty() && wp->shortname != wp->description) {
+#else
notes = wp->notes;
if (notes == NULL && wp->description && strcmp(wp->shortname, wp->description)) {
- notes = wp->description;
+#endif
+ notes = xstrdup(wp->description);
}
if (notes) {
notes_size = strlen(notes) + 1;
} else {
get_gc_notes(wp, &symbol, ¬es, ¬es_size);
notes_freeable = notes;
+#if NEW_STRINGS
+ if (!wp->description.isEmpty()) {
+#else
if (wp->description) {
+#endif
name = mkshort(mkshort_handle, wp->description);
}
}
}
}
- name_size = strlen(name) + 1;
+ name_size = strlen(CSTRc(name)) + 1;
if (name_size > 255) {
name_size = 255;
}
}
p->symbol = symbol;
p->name_size = name_size;
- memcpy(p->name, name, name_size - 1);
+ memcpy(p->name, CSTRc(name), name_size - 1);
p->name[name_size - 1] = 0;
pp = p->name + name_size;
m.size = (pp + 2 + notes_size) - (char*)p;
pp[2] = 0;
} else {
le_write16(pp, notes_size);
+#if NEW_STRINGS
+#else
if (notes) {
memcpy(pp + 2, notes, notes_size - 1);
pp[2 + notes_size - 1] = 0;
}
+#endif
}
add_to_batch(MSG_WAYPOINT_IN, &m);
if (extended_notes_size) {
- write_waypoint_notes(notes, extended_notes_size, name);
+ write_waypoint_notes(notes, extended_notes_size, CSTRc(name));
}
if (notes_freeable) {
xfree(notes_freeable);
}
if (global_opts.debug_level >= DBGLVL_L) {
- warning(MYNAME ": wrote waypoint %u '%s'\n", waypoint_i, name);
+ warning(MYNAME ": wrote waypoint %u '%s'\n", waypoint_i, CSTRc(name));
}
}
m.size = MSG_REQUEST_TRACKS_SIZE;
memset(m.data, 0, m.size);
((char*)m.data)[0] = 1; // Download single track
- strcpy((char*)m.data + 1, track->rte_name);
+ strcpy((char*)m.data + 1, CSTRc(track->rte_name));
message_write(MSG_REQUEST_TRACKS, &m);
if (get_batch(&msg_array, &msg_array_n)) {
break;
if (waypoint_n == 0) {
return;
}
+#if NEW_STRINGS
+ if (!track->rte_desc.isEmpty()) {
+#else
if (track->rte_desc) {
- comment_size = strlen(track->rte_desc) + 1;
+#endif
+ comment_size = strlen(CSTRc(track->rte_desc)) + 1;
}
message_init_size(&m, sizeof(msg_track_header_in_t) - 1 + comment_size);
p = (msg_track_header_in_t*) m.data;
memset(p->name, 0, sizeof(p->name));
+#if NEW_STRINGS
+ if (!track->rte_name.isEmpty()) {
+#else
if (track->rte_name) {
- strncpy(p->name, track->rte_name, sizeof(p->name) - 1);
+#endif
+ strncpy(p->name, CSTRc(track->rte_name), sizeof(p->name) - 1);
} else {
sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime().toTime_t());
}
le_write16(p->color, track_color_index(track->line_color.bbggrr));
le_write16(p->comment_size, comment_size);
if (comment_size) {
- memcpy(p->comment, track->rte_desc, comment_size);
+ memcpy(p->comment, CSTRc(track->rte_desc), comment_size);
}
add_to_batch(MSG_TRACK_HEADER_IN, &m);
write_track_points();
}
if (fd->memlen) {
gbfputc(0, fd);
+#if NEW_STRINGS
+ // Reconsider if there's a less grubby way to do this.
+ wp->notes = QString::fromUtf8((const char*) fd->handle.mem, fd->memlen);
+#else
wp->notes = (char*) xmalloc(fd->memlen);
memcpy(wp->notes, fd->handle.mem, fd->memlen);
+#endif
}
gbfclose(fd);
return wp;
m.size = MSG_REQUEST_ROUTES_SIZE;
memset(m.data, 0, m.size);
((char*)m.data)[0] = 1; // Download single route
- strcpy((char*)m.data + 1, route->rte_name);
+ strcpy((char*)m.data + 1, CSTRc(route->rte_name));
message_write(MSG_REQUEST_ROUTES, &m);
if (get_batch(&msg_array, &msg_array_n)) {
break;
shape_n = shape_point_counts[route_point_i];
le_write32(p->total, route_point_n);
le_write32(p->index, route_point_i);
+#if NEW_STRINGS
+ if (!wp->shortname.isEmpty()) {
+#else
if (wp->shortname) {
- strncpy(p->name, wp->shortname, sizeof(p->name) - 1);
+#endif
+ strncpy(p->name, CSTRc(wp->shortname), sizeof(p->name) - 1);
} else {
sprintf(p->name, "RPT%u", route_point_i);
}
static void
write_route_point(const waypoint* wp)
{
- const char* s = wp->shortname;
wp_array[waypoint_i++] = (waypoint*)wp;
+#if NEW_STRINGS
+ if (wp->shortname.startsWith("SHP")) {
+#else
+ const char* s = wp->shortname;
if (s && s[0] == 'S' && s[1] == 'H' && s[2] == 'P' && s[3] >= '0' && s[3] <= '9') {
+#endif
shape_point_n++;
shape_point_counts[route_point_n]++;
} else {
message_init_size(&m, sizeof(msg_route_header_in_t));
p = (msg_route_header_in_t*) m.data;
memset(p->name, 0, sizeof(p->name));
+#if NEW_STRINGS
+ if (!route->rte_name.isEmpty()) {
+#else
if (route->rte_name) {
- strncpy(p->name, route->rte_name, sizeof(p->name) - 1);
+#endif
+ strncpy(p->name, CSTRc(route->rte_name), sizeof(p->name) - 1);
} else {
sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime().toTime_t());
}
}
// vi: ts=4 sw=4 noexpandtab
-#endif
#include "garmin_fs.h"
#include "garmin_device_xml.h"
-#if REALLY_MINIMAL
-// I just don't want to cope with this format right now.
-ff_vecs_t garmin_vecs = { };
-#else
-
-#define SOON 1
-
#define MYNAME "GARMIN"
static const char* portname;
static short_handle mkshort_handle;
if (way[i]->time_populated) {
wpt_tmp->SetCreationTime(way[i]->time);
}
-#if SOON
garmin_fs_garmin_after_read(way[i], wpt_tmp, gps_waypt_type);
-#endif
waypt_add(wpt_tmp);
GPS_Way_Del(&way[i]);
}
* cleaning
*/
ident = mkshort(mkshort_handle,
- global_opts.synthesize_shortnames ? src :
- wpt->shortname);
+ global_opts.synthesize_shortnames ? CSTRc(src) :
+ CSTRc(wpt->shortname));
/* Should not be a strcpy as 'ident' isn't really a C string,
* but rather a garmin "fixed length" buffer that's padded
* to the end with spaces. So this is NOT (strlen+1).
// If we were explictly given a comment from GPX, use that.
// This logic really is horrible and needs to be untangled.
+#if NEW_STRINGS
+ if (!wpt->description.isEmpty() &&
+#else
if (wpt->description &&
+#endif
global_opts.smart_names && !wpt->gc_data->diff) {
- memcpy(tx_waylist[i]->cmnt, wpt->description, strlen(wpt->description));
+ memcpy(tx_waylist[i]->cmnt, CSTRc(wpt->description), strlen(CSTRc(wpt->description)));
} else {
if (global_opts.smart_names &&
wpt->gc_data->diff && wpt->gc_data->terr) {
snprintf(obuf, sizeof(obuf), "%s%d/%d %s",
get_gc_info(wpt),
wpt->gc_data->diff, wpt->gc_data->terr,
- src);
+ CSTRc(src));
memcpy(tx_waylist[i]->cmnt, obuf, strlen(obuf));
} else {
- memcpy(tx_waylist[i]->cmnt, src, strlen(src));
+ memcpy(tx_waylist[i]->cmnt, CSTRc(src), strlen(CSTRc(src)));
}
}
if (categorybits) {
tx_waylist[i]->category = categorybits;
}
-#if SOON
garmin_fs_garmin_before_write(wpt, tx_waylist[i], gps_waypt_type);
-#endif
i++;
}
{
(*cur_tx_routelist_entry)->rte_num = rte->rte_num;
(*cur_tx_routelist_entry)->isrte = 1;
+#if NEW_STRINGS
+ if (!rte->rte_name.isEmpty()) {
+#else
if (rte->rte_name) {
- strncpy((*cur_tx_routelist_entry)->rte_ident, rte->rte_name,
+#endif
+ strncpy((*cur_tx_routelist_entry)->rte_ident, CSTRc(rte->rte_name),
sizeof((*cur_tx_routelist_entry)->rte_ident));
}
}
route_waypt_pr(const waypoint* wpt)
{
GPS_PWay rte = *cur_tx_routelist_entry;
- char* s, *d;
/*
* As stupid as this is, libjeeps seems to want an empty
// enforce that here, since jeeps doesn't.
//
// This was strncpy(rte->ident, wpt->shortname, sizeof(rte->ident));
+ char* s, *d;
d = rte->ident;
+#if NEW_STRINGS
+ for (int idx = 0; idx < wpt->shortname.length(); idx++) {
+ int c = wpt->shortname[idx].toAscii();
+#else
for (s = wpt->shortname; *s; s++) {
int c = *s;
+#endif
if (receiver_must_upper && isalpha(c)) {
c = toupper(c);
}
track_hdr_pr(const route_head* trk_head)
{
(*cur_tx_tracklist_entry)->ishdr = gpsTrue;
+#if NEW_STRINGS
+ if (!trk_head->rte_name.isEmpty()) {
+#else
if (trk_head->rte_name) {
- strncpy((*cur_tx_tracklist_entry)->trk_ident, trk_head->rte_name, sizeof((*cur_tx_tracklist_entry)->trk_ident));
+#endif
+ strncpy((*cur_tx_tracklist_entry)->trk_ident, CSTRc(trk_head->rte_name), sizeof((*cur_tx_tracklist_entry)->trk_ident));
(*cur_tx_tracklist_entry)->trk_ident[sizeof((*cur_tx_tracklist_entry)->trk_ident)-1] = 0;
} else {
sprintf((*cur_tx_tracklist_entry)->trk_ident, "TRACK%02d", my_track_count);
(*cur_tx_tracklist_entry)->lon = wpt->longitude;
(*cur_tx_tracklist_entry)->alt = (wpt->altitude != unknown_alt) ? wpt->altitude : 1e25;
(*cur_tx_tracklist_entry)->Time = wpt->GetCreationTime().toTime_t();;
+#if NEW_STRINGS
+ if (!wpt->shortname.isEmpty()) {
+#else
if (wpt->shortname) {
- strncpy((*cur_tx_tracklist_entry)->trk_ident, wpt->shortname, sizeof((*cur_tx_tracklist_entry)->trk_ident));
+#endif
+ strncpy((*cur_tx_tracklist_entry)->trk_ident, CSTRc(wpt->shortname), sizeof((*cur_tx_tracklist_entry)->trk_ident));
(*cur_tx_tracklist_entry)->trk_ident[sizeof((*cur_tx_tracklist_entry)->trk_ident)-1] = 0;
}
(*cur_tx_tracklist_entry)->tnew = wpt->wpt_flags.new_trkseg;
}
return 0;
}
-#endif